<template>
  <div id="star-pic-vue">
    <template v-if="isShow">
      <el-dialog modal width="80%" :visible.sync="centerDialogVisible" :append-to-body="true" close-on-click-modal custom-class="dialog" v-if="isShow" :before-close="hidePreview">
        <el-image :src="data" fit="scale-down"></el-image>

        <span slot="footer" class="dialog-footer">
          <el-button @click="hidePreview">取 消</el-button>
          <el-button type="primary" @click="downloadImg">下 载</el-button>
        </span>
      </el-dialog>
    </template>
  </div>
</template>

<script>
  export default {
    name: 'star-pic-list',
    props: ['data', 'isShow'],
    data() {
      return {
        centerDialogVisible: true,
        isDialogShow: true,
      };
    },
    computed: {},
    methods: {
      hidePreview() {
        this.$emit('hide-preview');
      },
      downloadImg() {
        let a = document.createElement('a');
        a.style.display = 'none';
        a.setAttribute('href', this.data);
        //这块是保存图片操作  可以设置保存的图片的信息
        a.setAttribute('download', this.$route.query.processName + '.png');
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);

        setTimeout(() => {
          this.hidePreview();
        }, 1500);
      },
    },
  };
</script>

<style lang="scss">
  #star-pic-vue {
    width: 200px;
    height: auto;
    display: flex;
    flex-wrap: wrap;
    img {
      width: 80px;
      height: 80px;
      margin: 4px;
    }
    .dialog {
      img {
        width: 200px;
        height: 200px;
        margin: 0;
      }
    }
    .el-carousel__item h3 {
      color: #475669;
      font-size: 18px;
      opacity: 0.75;
      line-height: 300px;
      margin: 0;
      height: 100%;
      width: 100%;
    }
    .el-dialog__header {
      display: none;
    }
    .el-dialog__body {
      padding: 0 !important;
      margin: 0 !important;
      height: 600px;
    }
    .el-carousel {
      height: 100%;
    }
    .el-carousel__container {
      height: 100%;
    }
  }
</style>
